<template>
  <div class="playpage" :class="{ playing: playing }">
    <div
    v-if="currentPlaySong.picUrl"
      class="mask"
      :style="{
        backgroundImage:
          'url(' + currentPlaySong.picUrl  + ')'
      }"
    ></div>
    <div
    v-else
      class="mask"
      :style="{
        backgroundImage:
          'url('+
          currentPlaySong.al.picUrl  + ')'
      }"
    ></div>

    <div class="header">
      <div class="close" @click="$parent.isFullScreen = false"></div>
      <div class="title">
        <div>
          <h5>{{ currentPlaySong.name }} -</h5>
          <p>
            <span
              v-for="(artist, index) in currentPlaySong.song
                ? currentPlaySong.song.artists
                : currentPlaySong.ar"
              :key="index"
              class="artist"
              >{{ artist.name }}</span
            >
          </p>
        </div>
      </div>
    </div>

    <section
      style="width: 100%; height: calc(100vh - 150px); position: relative"
    >
      <KeepAlive>
        <PlayBo
          v-if="showDisc"
          @click.native="showDisc = false"
          :currentPlaySong="currentPlaySong"
          :class="{ playing: playing }"
        ></PlayBo>
        <PlayLyric
          v-else
          @click.native="showDisc = true"
          :currentPlaySongId="currentPlaySong.id"
          :currentTime="currentTime"
          :playing="playing"
        ></PlayLyric>
      </KeepAlive>
    </section>
    <div class="footer">
      <div class="progress">
        <input
          type="range"
          min="0"
          :max="duration"
          v-model="value"
          @change="changeHandler"
          @input="inputing = true"
        />
        <div class="bar">
          <span :style="{ width: (value / duration) * 100 + '%' }"></span>
        </div>
      </div>

      <transition name="fade">
        <div class="suiji" v-if="falg">
          <!-- {{}} -->
          <span v-if="playMode === 'sx'">顺序播放</span>
          <span v-else>随机播放</span>
        </div>
      </transition>
      <div class="controler">
        <span @click="showfalg" :class="{ active: playMode !== 'sx' }">
          <!-- <BoFang :change="change"/> -->
        </span>
        <!-- <span @click="$emit('suijibof')" v-else></span> -->
        <span @click="$parent.playPreSong"></span>
        <span @click="$emit('toggle-play', !playing)"></span>
        <span @click="$parent.playNextSong"></span>
        <span @click="$emit('toggle-gedan', true)"></span>
      </div>
    </div>
  </div>
</template>

<script>
// import BoFang from "@/components/BoFang.vue";
import PlayLyric from "@/components/PlayLyric.vue";
import PlayBo from "./PlayBo.vue";

export default {
  props: ["currentPlaySong", "playing", "currentTime", "duration", "playMode"],
  components: {
    // BoFang,
    PlayLyric,
    PlayBo,
  },
  data: function () {
    return {
      inputing: false,
      value: this.currentTime,
      showDisc: true,
      falg: false,
      // xus:["sx","sj"],
      // change:String,
      // a:0,
    };
  },

  methods: {
    changeHandler: function () {
      this.inputing = false;
      this.$emit("update:current-time", this.value);
    },
    showfalg() {
      this.$emit("suijibof");
      // console.log(123);
      this.falg = true;
      setTimeout(() => {
        this.falg = false;
      }, 1000);
    },
    // Change:function(){
    //   this.a = this.a++;

    // }
  },

  watch: {
    currentTime: function (n) {
      if (!this.inputing) {
        this.value = n;
      }
    },
  },
};
</script>

<style lang="less" scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
.playpage {
  width: 100vw;
  height: 100vh;
  background-color: rgb(39, 39, 39);
  position: fixed;
  top: 0;
  left: 0;
  overflow: hidden;
  color: white;
  padding: 10px;
  .mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-size: cover;
    background-position: center;
    filter: blur(50px) brightness(0.6);
    transform: scale(1.2);
  }
  .header {
    display: flex;
    // background: red;
    align-items: center;
    line-height: 30px;
    margin-bottom: 10px;
    .close {
      width: 30px;
      height: 30px;
      background: url("../assets/dj3.png") no-repeat;
      background-size: 60%;
      background-position: center;
    }
    .title {
      display: flex;
      font-size: 14px;
      color: lightgray;
      // white-space: nowrap;
      flex: 1;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      overflow: hidden;

      div {
        display: flex;
        white-space: nowrap;

        h5 {
        }
        p {
        }
      }
    }
  }

  .footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;

    .progress {
      position: relative;
      margin: 9px 0;
      input {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1;
        height: 100%;
        opacity: 0;
      }
      .bar {
        width: 100%;
        height: 2px;
        background: rgba(255, 255, 255, 0.1);
        span {
          display: block;
          height: 100%;
          width: 0%;
          background: rgba(255, 255, 255, 0.1);
          align-items: center;
          position: relative;

          &::after {
            content: "";
            display: block;
            width: 8px;
            height: 8px;
            background: white;
            // transform: translate(5px, -4px);
            position: absolute;
            right: -5px;
            top: -3px;
            border-radius: 50%;
          }
        }
      }
    }
    .suiji {
      position: absolute;
      top: -20px;
      left: 50%;
      transform: translateX(-50%);
      background: gray;
      padding: 5px 10px;
      border-radius: 10px;
    }

    .controler {
      display: flex;
      justify-content: center;
      align-items: center;

      span {
        width: 30px;
        height: 30px;
        // background: green;
        display: block;
        margin: 10px;
        background-image: url("../assets/dsx.png");
        background-size: 100%;
        background-position: center;
        &:nth-child(1) {
          background-image: url("../assets/duq.png");
          &.active {
            background-image: url("../assets/dv7.png");
          }
        }

        &:nth-child(2) {
          background-image: url("../assets/dsz.png");
        }
        &:nth-child(3) {
          width: 50px;
          height: 50px;
        }
        &:nth-child(4) {
          background-image: url("../assets/dst.png");
        }
        &:nth-child(5) {
          background-image: url("../assets/dvd.png");
        }
      }
    }
  }

  &.playing {
    .footer {
      .controler {
        span {
          &:nth-child(3) {
            background-image: url("../assets/dsv.png");
          }
        }
      }
    }
  }
}
</style>
